// app/service/user.js
const Service = require('egg').Service;

class ShopService extends Service {

  // 获取团购列表
  async getShoplist() {
    let sql = `select * from shop`;
    const res = await this.ctx.app.mysql.query(sql, []);
    if (res.length > 0) {
      return {
        status: true,
        code: 200,
        message: '获取直播列表成功',
        data: res
      }
    } else {
      return {
        status: false,
        code: 403,
        message: '获取直播列表失败',
        data: []
      }
    }
  }

  //删除团购列表
  async dleteShop(params) {
    let { id } = params;
    let sql = `delete from shop where id = ?`;
    const res = await this.ctx.app.mysql.query(sql, [id]);
    if (res.length > 0) {
      return {
        status: true,
        code: 200,
        message: '删除成功',
        data: res
      }
    } else {
      return {
        status: false,
        code: 403,
        message: '删除失败',
        data: []
      }
    }
  }


}

module.exports = ShopService;